import * as Loadable from "react-loadable" //https://github.com/thejameskyle/react-loadable
import loading from "../components/loading"

export const lazyRoutes = config =>
  config.map(route => ({
    ...route,
    component: Loadable({
      loader: route.component,
      loading: route.loading || loading,
      delay: 500,
      timeout: 2000,
    })
  }))
